// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  compatibilityDate: '2024-11-01',
  devtools: { enabled: true },
  css: ['element-plus/dist/index.css'],
  router: {
    middleware: ['auth']
  },
  modules: [
    '@pinia/nuxt',
    // "@pinia-plugin-persistedstate/nuxt"
  ],
  // extendRoutes(routes, resolve) {
  //   routes.push({
  //     path: '/login',
  //     component: resolve(__dirname, 'pages/login.vue')
  //   });
  // },
  pinia: {
    autoImports: [
      'defineStore', // import { defineStore } from 'pinia'
      // 其他自动导入的函数
    ]
  },
  piniaPersistedstate: {
    storage: 'sessionStorage' // + 持久化
  },
  runtimeConfig: {
    public: {
      apiBase: process.env.NUXT_PUBLIC_API_BASE,
    },
  },
  // 其他配置项
  // nitro: {
  //   devProxy: {
  //     '/meio': {
  //       target: 'http://192.168.1.33:8084',
  //       changeOrigin: true,
  //       pathRewrite: {'^/meio': "/meio"},
  //       prependPath: true,
  //     },
  //   },
  //   routeRules: {
  //     '/meio': {
  //       proxy: 'http://192.168.1.33:8084',
  //     },
  //   },
  //   middleware: ['proxy'],
  // }
  vite: {
    server: {
      proxy: {
        '/meio': {
          target: 'http://192.168.1.33:8084',
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/meio/, '/meio')
        }
      }
    }
  },
  routeRules: {
    '/meio/': {
      proxy: process.env.NUXT_PUBLIC_API_BASE, // 代理后台接口请求
      ssr: false,
      robots: false // 禁止爬取
    }
  },
  plugins: [
    '~/plugins/crypto.ts',
  ],
})
